package c_001;

/**
 * synchronized 关键字
 */
public class T01 {

    private int count = 10;
    private Object o = new Object();

    public void m(){
        synchronized (o){ //任何线程想访问下面代码,必须先拿到o的锁
            //所以说锁并不是说去锁count对象,而是说是要去拿到指定对象的锁这里指(o)
            count--;
            System.out.println(Thread.currentThread().getName() + " count = " + count);
        }
    }


}
